//
//  SettingController.m
//  CMJWeibo
//
//  Created by BH on 16/1/8.
//
//

#import "SettingController.h"
#import "CMJCommonArrowItem.h"
#import "CMJCommonGroup.h"
#import "UIImage+MJ.h"
#import "UIView+MJ.h"
#import "CMJCommon.h"
#import "GeneralSettingController.h"

@interface SettingController ()

@end

@implementation SettingController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"设置";
    
    [self setupItems];
    
    [self setupFooter];
}

-(void)setupItems
{
    //0组
    CMJCommonArrowItem *account = [CMJCommonArrowItem itemWithTitle:@"账号管理"];
    
    CMJCommonGroup *group0 = [self addGroup];
    group0.items = @[account];
    
    //1组
    CMJCommonArrowItem *notice = [CMJCommonArrowItem itemWithTitle:@"通知"];
    
    CMJCommonArrowItem *safe = [CMJCommonArrowItem itemWithTitle:@"隐私与安全"];
    
    CMJCommonArrowItem *general = [CMJCommonArrowItem itemWithTitle:@"通用设置"];
    general.destVc = [GeneralSettingController class];
    
    CMJCommonGroup *group1 = [self addGroup];
    group1.items = @[notice,safe,general];
    
    //2组
    CMJCommonArrowItem *cache = [CMJCommonArrowItem itemWithTitle:@"清理缓存"];
    
    CMJCommonArrowItem *suggust = [CMJCommonArrowItem itemWithTitle:@"意见反馈"];
    
    CMJCommonArrowItem *about = [CMJCommonArrowItem itemWithTitle:@"关于微博"];
    
    CMJCommonGroup *group2 = [self addGroup];
    group2.items = @[cache,suggust,about];
}

/**
 *  设置底部控件
 */
-(void)setupFooter
{
    //退出当前账号按钮
    UIButton *logout = [[UIButton alloc] init];
    [logout setTitle:@"退出当前账号" forState:UIControlStateNormal];
    [logout setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [logout setBackgroundImage:[UIImage resizableImage:@"common_card_background"] forState:UIControlStateNormal];
    [logout setBackgroundImage:[UIImage resizableImage:@"common_card_background_highlighted"] forState:UIControlStateHighlighted];
    logout.titleLabel.font = [UIFont systemFontOfSize:15];
    logout.height = 35;
    self.tableView.tableFooterView = logout;
    
    self.tableView.sectionFooterHeight = 10;
    self.tableView.sectionHeaderHeight = 0;
    
    if (!iOS7) {
        self.tableView.contentInset = UIEdgeInsetsMake(10, 0, 0, 0);
    }
}

@end
